<?php
$this->breadcrumbs=array(
		'Quản trị'=>array('/admin'),
		'Tin tức'=>array('index'),
		'Danh sách tin',
);

$this->menu=array(
		array('label'=>'Đăng tin', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
		$('.search-button').click(function(){
		$('.search-form').toggle();
		return false;
});
		$('.search-form form').submit(function(){
		$.fn.yiiGridView.update('news-grid', {
		data: $(this).serialize()
});
		return false;
});
		");
?>

<h1>Danh sách tin</h1>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
	<?php $this->renderPartial('_search',array(
			'model'=>$model,
)); ?>
</div>
<!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
		'id'=>'news-grid',
		'dataProvider'=>$model->search(),
		//'filter'=>$model,
		'columns'=>array(
				'id',
				'title',
				//'body',
				array('name'=>'create_time','value'=>'date("d/m/Y H:i",$data->create_time)'),
				array('name'=>'user_id','value'=>'$data->user->username'),
				 array('name'=>'status','value'=>'$data->status == 1 ? "Xuất bản":"Không xuất bản"'),
				array(
						'class'=>'CButtonColumn',
						'template'=>'{cview}{delete}{update}',
						'buttons'=> array(
								'cview'=>array(
										'options'=>array('target'=>'_blank'),
										'imageUrl'=>Yii::app()->request->baseUrl.'/images/view.png',
										'url'=>'Yii::app()->createUrl("/news/view", array("id"=>$data->id,"title"=>Yii::app()->func->safeTitle($data->title)))'
										),
								),
						
				),
		),
)); ?>
